var appControllers = angular.module('appControllers', []);

appControllers.controller('page1', [ '$scope', '$http',
    function ($scope, $http) {
        $http.get('home').success(function (data) {
            $scope.list = angular.fromJson(data);
        });
        $scope.form = {};
        $scope.form.name = 'Organization 1';
        $scope.form.person = {};
        $scope.form.person.name = 'Person 1';
        $scope.submit = function (form) {
            var config = angular.toJson(form);
            if (form.name && form.person.name) {
                $http.post('home', config).success(function (data) {
                    $scope.list = angular.fromJson(data);
                });
                form.name = '';
                form.person.name = '';
            }
        };

        $scope.name = 'App Home';
    } ]);

appControllers.controller('page2', [ '$scope', function ($scope) {
    // $scope.phoneId = $routeParams.phoneId;
} ]);

// appControllers.controller('page2', [ '$scope', '$routeParams',
// function($scope, $routeParams) {
// $scope.phoneId = $routeParams.phoneId;
// } ]);
